from PIL import Image
import os

dir_images = '/Users/edgar/Desktop/Philippines/ROLLER FOR FOLDING DOOR/original'


def test_resize(fold=dir_images):
    for file in os.listdir(fold):
        print(file)
        if file.endswith('png') or file.endswith('jpg'):
            print(file)
            path = os.path.join(fold, file)
            im = Image.open(path)
            width, height = im.size
            if width > 2000:
                im1 = im.resize((width // 2, height // 2))
                im1.save(path)


if __name__ == '__main__':
    test_resize()
